package com.example.task1.ui.AllService.subway;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.application.MyApplication;
import com.example.task1.bean.SubwayLostAndFoundBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class SubwayLostAndFoundDetailAdapter extends BaseAdapter<SubwayLostAndFoundBean.DataDTO.MetroFoundListDTO> {

    private Context context;
    private List<SubwayLostAndFoundBean.DataDTO.MetroFoundListDTO> mData = new ArrayList<>();
    private ImageView image;
    private TextView tvFoundPlace;
    private TextView tvClaimPlace;
    private TextView tvTime;

    public SubwayLostAndFoundDetailAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected void setData(List<SubwayLostAndFoundBean.DataDTO.MetroFoundListDTO> rows) {
        mData = rows;
        notifyDataSetChanged();
    }

    @Override
    protected int getLayout() {
        return R.layout.subwaylostandfountdetaillist;
    }

    @Override
    protected Context getContext() {
        return null;
    }

    @Override
    protected List<SubwayLostAndFoundBean.DataDTO.MetroFoundListDTO> getData() {
        return mData;
    }

    @Override
    protected void onBind(myHolder holder, SubwayLostAndFoundBean.DataDTO.MetroFoundListDTO date) {
        tvClaimPlace.setText(date.getClaimPlace());
        tvFoundPlace.setText(date.getFoundPlace());
        tvTime.setText(date.getFoundTime());
        MyApplication.glide(image, date.getImgUrl());
    }

    @Override
    protected void holder(View view) {
        initView(view);
    }

    private void initView(View view) {
        image = view.findViewById(R.id.image);
        tvFoundPlace = view.findViewById(R.id.tv_foundPlace);
        tvClaimPlace = view.findViewById(R.id.tv_claimPlace);
        tvTime = view.findViewById(R.id.tv_time);
    }
}
